package com.example.myapplication.old.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.example.myapplication.old.GameFragment;
import com.example.myapplication.activity.SoftwareFragment;

public class ViewPageAdapter extends FragmentPagerAdapter {
    private String[] key = {"游戏栏","软件栏"};
    public ViewPageAdapter(@NonNull FragmentManager fm) {
        super(fm);
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return position%2==0 ? new GameFragment() : new SoftwareFragment();
    }

    @Override
    public int getCount() {
        return 2;
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return key[position];
    }
}
